package main

import (
	"context"
	"flag"
	"github.com/zeromicro/go-zero/core/discov"
	"github.com/zeromicro/go-zero/zrpc"
	"log"
	"lover/rpc/rpc/sum/hello"
	"lover/rpc/rpc/sum/pb"
	"time"
)

func main() {
	flag.Parse()

	ticker := time.NewTicker(time.Second)
	defer ticker.Stop()
	client, err := zrpc.NewClient(zrpc.RpcClientConf{
		Etcd: discov.EtcdConf{
			Hosts: []string{"192.168.8.20:2379"},
			Key:   "sum.rpc",
		},
	})
	if err != nil {
		log.Fatal(err)
	}
	client.Conn()
	newHello := hello.NewHello(client)
	ping, err := newHello.Ping(context.Background(), &pb.SumRequest{Numbers: &pb.Numbers{
		A: 012,
		B: 12,
	}})
	if err != nil {
		panic(err)
	}
	log.Println(ping)
}
